import { InfiniteScrollViewCpnt } from "../../../../JKCore/Script/Components/InfiniteScrollViewCpnt";
import { JKManager } from "../../../../JKCore/Script/JKManager";
import { LocalizedLabel } from "../../../../JKCore/Script/Language/LocalizedLabel";
import { NormalViewBase } from "../../../../JKCore/Script/View/NormalViewBase";

const { ccclass, property } = cc._decorator;

type DataIsv = {
    row: number,
    longCol: number,
    shortCol: number,
}

type BubbleData = {
    id: string,
    x: number,
    y: number,
}

let RowItemSpace = -5,
    IdleOpacity = 50,
    DefaultBubbleId = `0`

/**
 * 登录界面
 */
@ccclass
export class MissionEditorView extends NormalViewBase {
    @property(cc.Prefab)
    pfbIsvCpnt: cc.Prefab = null;

    ndSettingCtn: cc.Node;
    ndIsvCpntCtn: cc.Node;
    ndRowItem: cc.Node;
    ndBubbleItem: cc.Node;
    ebRow: cc.EditBox;
    ebLongCol: cc.EditBox;
    ebshortCol: cc.EditBox;
    labRowCnt: LocalizedLabel;
    labBubblesCnt: LocalizedLabel;
    ndBubbleList: cc.Node;
    ndBubbleListCtn: cc.Node;
    ndNormalBubble: cc.Node;
    ndNormalBubbleCtn: cc.Node;
    ndBlockBubble: cc.Node;
    ndBlockBubbleCtn: cc.Node;
    ndDoubleBubble: cc.Node;
    ndDoubleBubbleCtn: cc.Node;
    ndBubbleListItem: cc.Node;
    scIsvCpnt: InfiniteScrollViewCpnt;
    ndSaving: cc.Node;
    ndBtnImport: cc.Node;
    ndBtnExport: cc.Node;
    ebImportPath: cc.EditBox;
    ebExportPath: cc.EditBox;
    private _gridData: { [y: number]: { [x: number]: string } };
    private _curBubbleId: string;
    private _mouseDownTarget: cc.Node;
    private _curBubble: cc.Node;
    private _bubbleSpfsMap: { [id: string]: cc.SpriteFrame };
    private _mouseDownButton: number;
    private _mouseDownButtonLeft: boolean;
    private _mouseDownButtonRight: boolean;
    private _bubblesRecord: BubbleData[];

    onLoad(): void {
        super.onLoad()
        cc.log(`${cc.js.getClassName(this)} onLoad`)

        // Ui
        this.ndSettingCtn = cc.find(`ndSetting/ndCtn`, this.node)
        this.ebRow = cc.find(`ebRow`, this.ndSettingCtn).getComponent(cc.EditBox)
        this.ebLongCol = cc.find(`ebLongCol`, this.ndSettingCtn).getComponent(cc.EditBox)
        this.ebshortCol = cc.find(`ebshortCol`, this.ndSettingCtn).getComponent(cc.EditBox)
        this.labRowCnt = cc.find(`labRowCnt`, this.ndSettingCtn).getComponent(LocalizedLabel)
        this.labBubblesCnt = cc.find(`labBubblesCnt`, this.ndSettingCtn).getComponent(LocalizedLabel)
        this.ndSaving = cc.find(`ndSaving`, this.node)
        this.ndBtnImport = cc.find(`ndBtnImport`, this.ndSaving)
        this.ndBtnExport = cc.find(`ndBtnExport`, this.ndSaving)
        this.ebImportPath = cc.find(`ebImportPath`, this.ndSaving).getComponent(cc.EditBox)
        this.ebExportPath = cc.find(`ebExportPath`, this.ndSaving).getComponent(cc.EditBox)

        // Isv
        this.ndIsvCpntCtn = cc.find(`ndIsvCpntCtn`, this.node)
        this.ndRowItem = cc.find(`ndRowItem`, this.ndIsvCpntCtn)
        this.ndBubbleItem = cc.find(`ndBubbleItem`, this.ndRowItem)
        this.ndBubbleItem.parent = null
        this.ndRowItem.parent = null
        this.scIsvCpnt = cc.instantiate(this.pfbIsvCpnt).getComponent(this.pfbIsvCpnt.data.name)
        this.ndIsvCpntCtn.addChild(this.scIsvCpnt.node)

        // BubbleList
        this.ndBubbleList = cc.find(`ndBubbleList`, this.node)
        this.ndBubbleListCtn = cc.find(`scrollView/view/content`, this.ndBubbleList)
        this.ndNormalBubble = cc.find(`ndNormalBubble`, this.ndBubbleListCtn)
        this.ndNormalBubbleCtn = cc.find(`ndCtn`, this.ndNormalBubble)
        this.ndBlockBubble = cc.find(`ndBlockBubble`, this.ndBubbleListCtn)
        this.ndBlockBubbleCtn = cc.find(`ndCtn`, this.ndBlockBubble)
        this.ndDoubleBubble = cc.find(`ndDoubleBubble`, this.ndBubbleListCtn)
        this.ndDoubleBubbleCtn = cc.find(`ndCtn`, this.ndDoubleBubble)
        this.ndBubbleListItem = cc.find(`ndBubbleListItem`, this.ndNormalBubbleCtn)
        this.ndBubbleListItem.parent = null
    }

    init(data: any): void {
        cc.log(`${cc.js.getClassName(this)} init data = `, data)

        // data = {
        // }

        // Ui
        let dataUi = {
        }
        this._dataUpdateTool.put(JKManager.Const.MissionEditorView.CpntName.Ui, dataUi)
        this.ebRow.node.on(`editing-did-ended`, (editbox: cc.EditBox) => {
            cc.log(`${cc.js.getClassName(this)} ebRow editing-did-ended`)

            this._dataUpdateTool.setCpntDataByName(JKManager.Const.MissionEditorView.CpntName.Isv, {
                row: Number(this.ebRow.string),
                longCol: Number(this.ebLongCol.string),
                shortCol: Number(this.ebshortCol.string),
            })
        })
        this.ebLongCol.node.on(`editing-did-ended`, (editbox: cc.EditBox) => {
            cc.log(`${cc.js.getClassName(this)} ebLongCol editing-did-ended`)

            this._dataUpdateTool.setCpntDataByName(JKManager.Const.MissionEditorView.CpntName.Isv, {
                row: Number(this.ebRow.string),
                longCol: Number(this.ebLongCol.string),
                shortCol: Number(this.ebshortCol.string),
            })
        })
        this.ebshortCol.node.on(`editing-did-ended`, (editbox: cc.EditBox) => {
            cc.log(`${cc.js.getClassName(this)} ebshortCol editing-did-ended`)

            this._dataUpdateTool.setCpntDataByName(JKManager.Const.MissionEditorView.CpntName.Isv, {
                row: Number(this.ebRow.string),
                longCol: Number(this.ebLongCol.string),
                shortCol: Number(this.ebshortCol.string),
            })
        })
        this.ndBtnImport.on(cc.Node.EventType.TOUCH_END, (event: cc.Event.EventTouch) => {
            cc.log(`${cc.js.getClassName(this)} onBtnImport`)

            this._importGridDate()
        }, this)
        this.ndBtnExport.on(cc.Node.EventType.TOUCH_END, (event: cc.Event.EventTouch) => {
            cc.log(`${cc.js.getClassName(this)} onBtnExport`)

            this._exportGridDate()
        }, this)
        this._bubblesRecord = []

        // Isv
        let dataIsv: DataIsv = {
            row: Number(this.ebRow.string),
            longCol: Number(this.ebLongCol.string),
            shortCol: Number(this.ebshortCol.string),
        }
        this._dataUpdateTool.put(JKManager.Const.MissionEditorView.CpntName.Isv, dataIsv)
        this.scIsvCpnt.setItemSpace(RowItemSpace)

        // BubbleList
        let dataBubbleList: [string[], string[], string[],] = [[], [], [],]
        this._dataUpdateTool.put(JKManager.Const.MissionEditorView.CpntName.BubbleList, dataBubbleList)
        this._curBubbleId = `1`
        this._bubbleSpfsMap = cc.js.createMap()
        this._bubbleSpfsMap[DefaultBubbleId] = new cc.SpriteFrame(this.ndBubbleItem.getComponent(cc.Sprite).spriteFrame.getTexture())
    }

    start(): void {
        cc.log(`${cc.js.getClassName(this)} start`)

        // Ui
        this._dataUpdateTool.registCpntUpdateWithName(JKManager.Const.MissionEditorView.CpntName.Ui, this._updateCpntUi.bind(this))
        this._updateCpntUi(this._dataUpdateTool.getCpntDataByName(JKManager.Const.MissionEditorView.CpntName.Ui), true)

        // Isv
        this._dataUpdateTool.registCpntUpdateWithName(JKManager.Const.MissionEditorView.CpntName.Isv, this._updateCpntIsv.bind(this))
        this._updateCpntIsv(this._dataUpdateTool.getCpntDataByName(JKManager.Const.MissionEditorView.CpntName.Isv), true)

        // BubbleList
        this._dataUpdateTool.registCpntUpdateWithName(JKManager.Const.MissionEditorView.CpntName.BubbleList, this._updateCpntBubbleList.bind(this))
        this._updateCpntBubbleList(this._dataUpdateTool.getCpntDataByName(JKManager.Const.MissionEditorView.CpntName.BubbleList), true)
    }

    update(dt: number): void {
        super.update(dt)
    }

    close(): void {
        cc.log(`${cc.js.getClassName(this)} close`)

        let data = {}
        JKManager.UiManager.backNormalView(data)
    }

    onDestroy(): void {
        cc.log(`${cc.js.getClassName(this)} onDestroy`)
    }

    // ====================================================================================
    // ===================================== 内部接口 ======================================
    // ====================================================================================

    /**
     * 刷新组件 Ui
     * @param data 数据对象
     * @param immediately 是否同步刷新
     */
    private _updateCpntUi(data: any, immediately: boolean = false): void {
        cc.log(`${cc.js.getClassName(this)} _updateCpntUi data = `, data)

        this._taskQueueTool.addCmd({
            cmd: JKManager.Const.MissionEditorView.Cmd.UpdateCpntUi,
            params: {},
            call: (cmd, params) => {
                cc.log(`${cc.js.getClassName(this)} Cmd.UpdateCpntUi params = `, params)

                this._taskQueueTool.doneCmd(cmd)
            }
        }, immediately)
    }

    /**
     * 刷新组件 Isv
     * @param data 数据对象
     * @param immediately 是否同步刷新
     */
    private _updateCpntIsv(data: DataIsv, immediately: boolean = false): void {
        cc.log(`${cc.js.getClassName(this)} _updateCpntIsv data = `, data)

        this._taskQueueTool.addCmd({
            cmd: JKManager.Const.MissionEditorView.Cmd.UpdateCpntIsv,
            params: {},
            call: (cmd, params) => {
                cc.log(`${cc.js.getClassName(this)} Cmd.UpdateCpntIsv params = `, params)

                this._gridData = this._gridData || cc.js.createMap()
                for (let y = 0; y < data.row; y++) {
                    let yData = this._gridData[y] || cc.js.createMap(),
                        yLen: number
                    if (y % 2 === 0) {
                        yLen = 11
                    } else {
                        yLen = 10
                    }
                    for (let x = 0; x < yLen; x++) {
                        yData[x] = yData[x] || DefaultBubbleId
                    }
                    for (let z = yLen; z < 11; z++) {
                        delete yData[z]
                    }
                    this._gridData[y] = yData
                }
                let xLen = Object.keys(this._gridData).length
                for (let y = data.row; y < xLen; y++) {
                    delete this._gridData[y]
                }
                xLen = Object.keys(this._gridData).length
                this.scIsvCpnt.init(xLen, (index: number, isIniting) => {
                    // cc.log(`${cc.js.getClassName(this)} onIsvCreateCall index = ${index}`)

                    let item: cc.Node = this.scIsvCpnt.getItemFromPoolWithName(this.ndRowItem.name) || cc.instantiate(this.ndRowItem),
                        yData = this._gridData[index],
                        yLen = Object.keys(yData).length
                    for (let x = 0; x < yLen; x++) {
                        let ndBubbleItem = item.children[x] || cc.instantiate(this.ndBubbleItem),
                            widget = ndBubbleItem.getComponent(cc.Widget)
                        ndBubbleItem.width = ndBubbleItem.height
                        !ndBubbleItem.parent && item.addChild(ndBubbleItem)
                        if (index === 0) {
                            item.height = this.ndRowItem.height - RowItemSpace
                            widget.top = 0
                            widget.bottom = 0
                            widget.isAlignTop = false
                            widget.isAlignBottom = true
                        } else if (index === xLen - 1) {
                            item.height = this.ndRowItem.height + 5
                            widget.top = 0
                            widget.bottom = 0
                            widget.isAlignTop = true
                            widget.isAlignBottom = false
                        } else {
                            item.height = this.ndRowItem.height
                            widget.top = 0
                            widget.bottom = 0
                            widget.isAlignTop = true
                            widget.isAlignBottom = true
                        }
                    }
                    for (let x = yLen; x < item.children.length; x++) {
                        let ndBubbleItem = item.children[x]
                        if (ndBubbleItem) {
                            ndBubbleItem.width = 0
                        }
                    }

                    return {
                        item: item,
                        poolName: item.name,
                    }
                }, (item: cc.Node, index: number, isActive, isIniting) => {
                    // cc.log(`${cc.js.getClassName(this)} onIsvActiveCall index = ${index} isActive = ${isActive}`)

                    if (isActive) {
                        let yData = this._gridData[index],
                            yLen = Object.keys(yData).length
                        for (let x = 0; x < yLen; x++) {
                            let id = yData[x],
                                ndBubbleItem = item.children[x]
                                if (this._bubbleSpfsMap) {
                                    let spBubble = ndBubbleItem.getComponent(cc.Sprite)
                                    spBubble.spriteFrame = this._bubbleSpfsMap[id]
                                }
                            ndBubbleItem.on(cc.Node.EventType.MOUSE_DOWN, (event: cc.Event.EventMouse) => {
                                cc.log(`${cc.js.getClassName(this)} onMouseDown`)

                                this._mouseDownTarget = event.target
                                this._mouseDownButton = event.getButton()
                                this._mouseDownButtonLeft = this._mouseDownButtonLeft || event.getButton() === cc.Event.EventMouse.BUTTON_LEFT
                                this._mouseDownButtonRight = this._mouseDownButtonRight || event.getButton() === cc.Event.EventMouse.BUTTON_RIGHT
                                cc.log(`${cc.js.getClassName(this)} this._mouseDownButtonLeft = ${this._mouseDownButtonLeft} this._mouseDownButtonRight = ${this._mouseDownButtonRight}`)
                                this.scIsvCpnt.lockScroll(!this._mouseDownButtonLeft || !this._mouseDownButtonRight)
                            }, this)
                            ndBubbleItem.on(cc.Node.EventType.MOUSE_MOVE, (event: cc.Event.EventMouse) => {
                                if (this._mouseDownTarget) {
                                    if (this._mouseDownButton === cc.Event.EventMouse.BUTTON_LEFT) {
                                        cc.log(`${cc.js.getClassName(this)} onMouseLeft`)

                                        this._setBubble(ndBubbleItem, this._curBubbleId, index, x)
                                    } else if (this._mouseDownButton === cc.Event.EventMouse.BUTTON_RIGHT) {
                                        cc.log(`${cc.js.getClassName(this)} onMouseRight`)

                                        this._setBubble(ndBubbleItem, DefaultBubbleId, index, x)
                                    }
                                }
                            }, this)
                            ndBubbleItem.on(cc.Node.EventType.MOUSE_UP, (event: cc.Event.EventMouse) => {
                                if (this._mouseDownTarget === event.target) {
                                    if (event.getButton() === cc.Event.EventMouse.BUTTON_LEFT) {
                                        cc.log(`${cc.js.getClassName(this)} onMouseLeft`)

                                        this._setBubble(ndBubbleItem, this._curBubbleId, index, x)
                                    } else if (event.getButton() === cc.Event.EventMouse.BUTTON_RIGHT) {
                                        cc.log(`${cc.js.getClassName(this)} onMouseRight`)

                                        this._setBubble(ndBubbleItem, DefaultBubbleId, index, x)
                                    }
                                }
                                this._mouseDownTarget = null
                                this._mouseDownButton = null
                                this._mouseDownButtonLeft = false
                                this._mouseDownButtonRight = false
                                this.scIsvCpnt.lockScroll(false)
                            }, this)
                        }
                    } else {
                        item.children.forEach((ndBubbleItem, x) => {
                            if (isIniting && index < Object.keys(this._gridData).length) {
                                this._setBubble(ndBubbleItem, DefaultBubbleId)
                            } else {
                                this._setBubble(ndBubbleItem, DefaultBubbleId, index, x)
                            }
                            ndBubbleItem.targetOff(this)
                        })
                    }
                }, false, true)

                this._taskQueueTool.doneCmd(cmd)
            }
        }, immediately)
    }

    /**
     * 刷新组件 BubbleList
     * @param data 数据对象
     * @param immediately 是否同步刷新
     */
    private _updateCpntBubbleList(data: [string[], string[], string[],], immediately: boolean = false): void {
        cc.log(`${cc.js.getClassName(this)} _updateCpntBubbleList data = `, data)

        this._taskQueueTool.addCmd({
            cmd: JKManager.Const.MissionEditorView.Cmd.UpdateCpntBubbleList,
            params: {},
            call: (cmd, params) => {
                cc.log(`${cc.js.getClassName(this)} Cmd.UpdateCpntBubbleList params = `, params)

                let loadBubbles = (dir: string, ndCtn: cc.Node) => {
                    cc.resources.loadDir(`BubbleShooter/Texture/Bubble/${dir}`, cc.SpriteFrame, (error: Error, spfs: cc.SpriteFrame[]) => {
                        if (error) {
                            cc.error(error)
                        } else {
                            spfs.forEach((spf: cc.SpriteFrame, index: number) => {
                                let id = spf.name,
                                    ndBubbleItem = ndCtn.children[index] || cc.instantiate(this.ndBubbleListItem),
                                    spNormalBubbleItem = ndBubbleItem.getComponent(cc.Sprite),
                                    ndBubble = cc.find(`ndBubble`, ndBubbleItem)
                                this._bubbleSpfsMap[id] = spf
                                !ndBubbleItem.parent && ndCtn.addChild(ndBubbleItem)
                                if (id === this._curBubbleId) {
                                    spNormalBubbleItem.enabled = true
                                    this._curBubble = ndBubbleItem
                                } else {
                                    spNormalBubbleItem.enabled = false
                                }
                                this._setBubble(ndBubble, id)
                                if (this._bubbleSpfsMap) {
                                    let spBubble = ndBubble.getComponent(cc.Sprite)
                                    spBubble.spriteFrame = this._bubbleSpfsMap[id]
                                }
                                ndBubbleItem.targetOff(this)
                                ndBubbleItem.on(cc.Node.EventType.TOUCH_END, (event: cc.Event.EventTouch) => {
                                    cc.log(`${cc.js.getClassName(this)} on${dir}Item`)

                                    this._curBubble.getComponent(cc.Sprite).enabled = false
                                    this._curBubble = ndBubbleItem
                                    this._curBubble.getComponent(cc.Sprite).enabled = true
                                    this._curBubbleId = id
                                }, this)
                            })
                        }
                    })
                }
                loadBubbles(`NormalBubble`, this.ndNormalBubbleCtn)
                loadBubbles(`BlockBubble`, this.ndBlockBubbleCtn)
                loadBubbles(`DoubleBubble`, this.ndDoubleBubbleCtn)

                this._taskQueueTool.doneCmd(cmd)
            }
        }, immediately)
    }

    // ====================================================================================

    private _setBubble(ndBubble: cc.Node, id: string, y: number = null, x: number = null) {
        // cc.log(`${cc.js.getClassName(this)} _setBubble`)

        if (y !== null && x !== null) {
            let yData = this._gridData[y]
            if (yData) {
                if (yData[x]) {
                    yData[x] = id
                }
                this._gridData[y] = yData
            }
        }
        if (this._bubbleSpfsMap) {
            let spBubble = ndBubble.getComponent(cc.Sprite)
            if (spBubble.spriteFrame.name !== id) {
                let bubbleData = cc.js.createMap()
                bubbleData.id = id
                bubbleData.x = x
                bubbleData.y = y
                if (id !== DefaultBubbleId) {
                    this._addBubblesRecord([bubbleData])
                    spBubble.spriteFrame = this._bubbleSpfsMap[id]
                } else {
                    this._removeBubblesRecord([bubbleData])
                    spBubble.spriteFrame = this._bubbleSpfsMap[DefaultBubbleId]
                }
                if (this._bubblesRecord.length > 0) {
                    this.labRowCnt.string = (this._bubblesRecord[this._bubblesRecord.length - 1].y + 1).toString()
                    this.labBubblesCnt.string = this._bubblesRecord.length.toString()
                } else {
                    this.labRowCnt.string = `0`
                    this.labBubblesCnt.string = `0`
                }
            }
        }
    }

    private _addBubblesRecord(bubbleDatas: BubbleData[]) {
        cc.log(`${cc.js.getClassName(this)} _addBubblesRecord`)

        bubbleDatas.forEach(bubbleData => {
            let x = bubbleData.x,
                y = bubbleData.y
            if (x !== null && y !== null) {
                if (this._bubblesRecord.length > 0) {
                    for (let index = this._bubblesRecord.length - 1; index >= 0; index--) {
                        const record = this._bubblesRecord[index]
                        let recordId = record.id,
                            recordX = record.x,
                            recordY = record.y
                        if (recordX === x && recordY === y) {
                            break
                        }
                        if (y > recordY) {
                            this._bubblesRecord.splice(index + 1, 0, bubbleData)

                            break
                        } else if (y === recordY) {
                            if (x < recordX) {
                                this._bubblesRecord.splice(index, 0, bubbleData)
                            } else {
                                this._bubblesRecord.splice(index + 1, 0, bubbleData)
                            }

                            break
                        } else if (index === 0) {
                            this._bubblesRecord.unshift(bubbleData)
                        }
                    }
                } else {
                    this._bubblesRecord.push(bubbleData)
                }
            }
        })
    }

    private _removeBubblesRecord(bubbleDatas: BubbleData[]) {
        cc.log(`${cc.js.getClassName(this)} _removeBubblesRecord`)

        bubbleDatas.forEach(bubbleData => {
            for (let index = 0; index < this._bubblesRecord.length; index++) {
                const record = this._bubblesRecord[index]
                if (record.x === bubbleData.x && record.y === bubbleData.y) {
                    this._bubblesRecord.splice(index, 1)

                    break
                }
            }
        })
    }

    private(ndBubble: cc.Node): boolean {
        cc.log(`${cc.js.getClassName(this)} _isBubbleIdle`)

        return ndBubble.opacity === IdleOpacity
    }

    private _exportGridDate() {
        cc.log(`${cc.js.getClassName(this)} _exportGridDate`)

        cc.log(JSON.stringify(this._gridData))
        let gridData: string[][] = []
        for (const y in this._gridData) {
            if (Object.prototype.hasOwnProperty.call(this._gridData, y)) {
                const _yData = this._gridData[y]
                let yData = []
                gridData.push(yData)
                for (const x in _yData) {
                    if (Object.prototype.hasOwnProperty.call(_yData, x)) {
                        const data = _yData[x]
                        let numData = Number(data)
                        yData.push(isNaN(numData) ? data : numData)
                    }
                }
            }
        }
        cc.log(gridData)
        let strData = JSON.stringify(gridData),
            path: string
        strData = strData.replace(/\[\[/ig, `{\n    "${this.ebExportPath.string || 0}": [\n        [`)
        strData = strData.replace(/\],/ig, `],\n        `)
        strData = strData.replace(/\]\]/ig, `]\n    ]\n}`)
        strData = strData.replace(/"\[/ig, `[`)
        strData = strData.replace(/\]"/ig, `]`)
        cc.log(strData)
        if (CC_JSB) {
            path = `${jsb.fileUtils.getWritablePath()}\\${this.ebExportPath.string}.json`
            jsb.fileUtils.writeStringToFile(strData, path)
        }
        JKManager.UiManager.showCommonDialogView(path, `ScaleIn`, () => {
            cc.log(`${cc.js.getClassName(this)} onConfirm`)
        })
    }

    private _importGridDate() {
        cc.log(`${cc.js.getClassName(this)} _importGridDate`)

        let path = `${this.ebImportPath.string}`
        if (CC_JSB) {
            if (jsb.fileUtils.isFileExist(path)) {
                try {
                    let strData = jsb.fileUtils.getStringFromFile(path)
                    this._gridData = JSON.parse(strData)
                    this._gridData = this._gridData[Object.keys(this._gridData)[0]]
                    let dataIsv: DataIsv = {
                        row: Object.keys(this._gridData).length,
                        longCol: Number(this.ebLongCol.string),
                        shortCol: Number(this.ebshortCol.string),
                    }
                    this._dataUpdateTool.setCpntDataByName(JKManager.Const.MissionEditorView.CpntName.Isv, dataIsv)
                } catch (error) {
                    JKManager.UiManager.showCommonDialogView(error, `ScaleIn`, () => {
                        cc.log(`${cc.js.getClassName(this)} onConfirm`)
                    })
                }
            } else {
                JKManager.UiManager.showCommonDialogView(`${path} is not exist!`, `ScaleIn`, () => {
                    cc.log(`${cc.js.getClassName(this)} onConfirm`)
                })
            }
        }
    }

    // ====================================================================================
    // ===================================== 外部接口 ======================================
    // ====================================================================================
}